package com.chuang.bootplus.controller.storage.tencent;


import com.chuang.bootplus.base.utils.ApiResponse;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;


/**
 * @description: TODO Test 测试用
 * @author nuo
 * @date 2022/10/10 1:28
 * @version 1.0
 */

@Api(tags = {"腾讯云"})
@RestController
@RequestMapping("storage/tencent")
@CrossOrigin
public class TencentDemoController {

    @Autowired
    TencentService tencentService;

    @PostMapping("/upload")
    @ApiOperation("上传...")
    public ApiResponse<Map<String, String>> upload(MultipartFile file) {
        return tencentService.upload(file);
    }

    @PostMapping("/download")
    @ApiOperation("下载...")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "key", value = "文件 id", example = "881f853eb9e34c0c8721b464c380f236.jpg"),
            @ApiImplicitParam(name = "path", value = "文件的保存路径", example = "F:\\"),
            @ApiImplicitParam(name = "fileName", value = "源文件名", example = "老实巴交.jpg")
    })
    public ApiResponse<String> download(String key, String path, String fileName) {
        return tencentService.download(key, path, fileName);
    }

    @PostMapping("/del")
    @ApiOperation("删除...")
    @ApiImplicitParam(name = "key", value = "文件 id", example = "f5e75ec0eebf4d66bec4f5024276fa4f.jpg")
    public ApiResponse<Void> del(String key) {
        return tencentService.del(key);
    }

}
